//***instanceof的学习***

class Fruit {}

class Apple extends Fruit {}

class Banana extends Fruit {}

public class instancef {
    public static void main(String[] args) {
        Fruit fruit = new Apple();
        Apple apple = new Apple();
        Banana banana = new Banana();

        boolean res1 = fruit instanceof Fruit;
        boolean res2 = fruit instanceof Apple;
        boolean res3 = apple instanceof Fruit;
        boolean res4 = banana instanceof Apple;

        System.out.println("fruit 是 Fruit 类型: " + res1);
        System.out.println("fruit 是 Apple 类型: " + res2);
        System.out.println("apple 是 Fruit 类型: " + res3);
        System.out.println("banana 是 Apple 类型: " + res4);
    }
}
